﻿using System.ComponentModel.DataAnnotations;

namespace ConsoleApp14
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int lenght,lenght2,Tempascii,ascii,middle=0,now=0;
            string Plaintext,cipher,Ciphertext="";
            Console.WriteLine("请输入一串字母");
            Plaintext=Console.ReadLine();
            Console.WriteLine("请输入按什么字符加密");
            cipher = Console.ReadLine();
            lenght = Plaintext.Length;
            lenght2 = cipher.Length;
            char[] mychars = Plaintext.ToCharArray();
            char[] mychars2 = cipher.ToCharArray();
            for (int i = 0; i < lenght; i++)
            { 
                Tempascii = ((int)mychars[i] - 97) + ((int)mychars2[now] - 97);
                now++;
                if(Tempascii>25)
                {
                    middle = Tempascii % 26;
                    ascii = 97 + middle;
                }
                else
                {
                    ascii = 97 + Tempascii;
                }
                Ciphertext += (char)ascii;
                if(now>=lenght2)
                    now = 0;
            }
            Console.WriteLine("加密后的暗文为");
            Console.WriteLine(Ciphertext);
        }
    }
}